package cn.jbit.easybuy.service.impl;

import java.util.List;

import cn.jbit.easybuy.dao.ProductCategoryDao;
import cn.jbit.easybuy.dao.impl.ProductCategoryDaoImpl;
import cn.jbit.easybuy.entity.ProductCategory;
import cn.jbit.easybuy.service.ProductCategoryService;

public class ProductCategoryServiceImpl implements ProductCategoryService {

	
	@Override
	public List<ProductCategory> findAll() {
		ProductCategoryDao dao = new ProductCategoryDaoImpl();
		//先查询一级分类
		List<ProductCategory> list = dao.findParentCategory();
		for (ProductCategory pc : list) {
			//遍历一级分类，分别去查询各自的二级分类，存储到属性childList中.
			List<ProductCategory> childList = dao.findChildCategory(pc.getId());
			pc.setChildList(childList);
		}
		
		return list;
	}

}
